<?php
class http
{
	public function http_curl($url, $data, $requestMethod = 'POST', $connTimeOut = 3, $sendHeader = 0, $timeOut = 8){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		if('post' == strtolower($requestMethod)){
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
		}else{
			curl_setopt($ch, CURLOPT_HTTPGET, true);
		}
		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//返回值存储到变量，而不是直接输出
		curl_setopt($ch, CURLOPT_HEADER, $sendHeader);//输出头信息
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connTimeOut);
		curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$result = curl_exec($ch);
		if (false == $result)
		{
			$result = null;
		}
		curl_close($ch);
		return $result;
	}
}